import { Controller, Get, Post, Param } from '@nestjs/common';
import { InitDataService } from './init-data.service';
import { ApiOperation, ApiTags, ApiBearerAuth } from '@nestjs/swagger';


@ApiTags('数据初始化')
@Controller('init-data')
@ApiBearerAuth()
export class InitDataController {
  constructor(private readonly initDataService: InitDataService) {}

  @ApiOperation({ summary: '获取可用的SQL文件列表' })
  @Get('files')

  async getSqlFiles() {
    const files = await this.initDataService.getSqlFiles();
    return files;
  }

  @ApiOperation({ summary: '执行指定SQL文件' })
  @Post('execute/:fileName')

  async executeSqlFile(@Param('fileName') fileName: string) {
    return this.initDataService.executeSqlFile(fileName);
  }

  @ApiOperation({ summary: '初始化所有数据' })
  @Post('init-all')
  async initAllData() {
    return this.initDataService.initAllData();
  }
} 
